listitemwidget: Have .activatable style class if the item is activatable
authorAlexander Mikhaylenko <alexm@gnome.org>
Mon, 17 May 2021 13:05:05 +0000 (18:05 +0500)
committerAlexander Mikhaylenko <alexm@gnome.org>
Mon, 17 May 2021 13:10:35 +0000 (18:10 +0500)
Match GtkListBox, so it's possible to use the same styles for them.

Update GtkListView and GtkGridView docs to reflect that, fix a few gtk-doc
formatting leftovers along the way.

gtk/gtkgridview.c
gtk/gtklistitem.c
gtk/gtklistitemwidget.c
gtk/gtklistitemwidgetprivate.h
gtk/gtklistview.c

index f32400d3cd6d4b3845fdd5d261992658f760cbd6..3de7f2f7c27573c44232e0b20a247f83c0917430 100644 (file)
  *
  * ```
  * gridview
- * ├── child
+ * ├── child[.activatable]
  * │
- * ├── child
+ * ├── child[.activatable]
  * │
  * ┊
  * ╰── [rubberband]
  * ```
  *
- * `GtkGridView` uses a single CSS node with name gridview. Each child
- * uses a single CSS node with name child. For rubberband selection,
- * a subnode with name rubberband is used.
+ * `GtkGridView` uses a single CSS node with name `gridview`. Each child uses
+ * a single CSS node with name `child`. If the [property@Gtk.ListItem.activatable]
+ * property is set, the corresponding row will have the `.activatable` style
+ * class. For rubberband selection, a subnode with name `rubberband` is used.
  *
  * # Accessibility
  *
index 89171369a5ae63cfb62c40e99aad8fc24c9c7b2d..b4371b8c932b77b7d1d4d6f3aa98355b8d485701 100644 (file)
@@ -460,5 +460,8 @@ gtk_list_item_set_activatable (GtkListItem *self,
 
   self->activatable = activatable;
 
+  if (self->owner)
+    gtk_list_item_widget_set_activatable (self->owner, activatable);
+
   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTIVATABLE]);
 }
index 09ac15d1bfc51e76f93641bf9a2dd2826aa516c5..2a98ef5c87e83bb900855b65f542e2cc20fc0eae 100644 (file)
@@ -509,6 +509,8 @@ gtk_list_item_widget_default_setup (GtkListItemWidget *self,
   if (list_item->child)
     gtk_list_item_widget_add_child (self, list_item->child);
 
+  gtk_list_item_widget_set_activatable (self, list_item->activatable);
+
   if (priv->item)
     g_object_notify (G_OBJECT (list_item), "item");
   if (priv->position != GTK_INVALID_LIST_POSITION)
@@ -531,6 +533,8 @@ gtk_list_item_widget_default_teardown (GtkListItemWidget *self,
   if (list_item->child)
     gtk_list_item_widget_remove_child (self, list_item->child);
 
+  gtk_list_item_widget_set_activatable (self, FALSE);
+
   if (priv->item)
     g_object_notify (G_OBJECT (list_item), "item");
   if (priv->position != GTK_INVALID_LIST_POSITION)
@@ -612,6 +616,16 @@ gtk_list_item_widget_set_single_click_activate (GtkListItemWidget *self,
   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SINGLE_CLICK_ACTIVATE]);
 }
 
+void
+gtk_list_item_widget_set_activatable (GtkListItemWidget *self,
+                                      gboolean           activatable)
+{
+  if (activatable)
+    gtk_widget_add_css_class (GTK_WIDGET (self), "activatable");
+  else
+    gtk_widget_remove_css_class (GTK_WIDGET (self), "activatable");
+}
+
 void
 gtk_list_item_widget_add_child (GtkListItemWidget *self,
                                 GtkWidget         *child)
index 8f78b1a7a28982e8062a41cfd19d6fad456b2d19..eca2d21c6bc75bca642a5debfce5aee4463f3b61 100644 (file)
@@ -74,6 +74,8 @@ void                    gtk_list_item_widget_set_factory        (GtkListItemWidg
 void                    gtk_list_item_widget_set_single_click_activate
                                                                 (GtkListItemWidget     *self,
                                                                  gboolean               single_click_activate);
+void                    gtk_list_item_widget_set_activatable    (GtkListItemWidget     *self,
+                                                                 gboolean               activatable);
 void                    gtk_list_item_widget_add_child          (GtkListItemWidget      *self,
                                                                  GtkWidget              *child);
 void                    gtk_list_item_widget_reorder_child      (GtkListItemWidget      *self,
index 63446efdb00e94a4cf86166365d86ffe16d6ccf0..624bfbd4fd92cea5a04d5c16c84f133984b72718 100644 (file)
  *
  * ```
  * listview[.separators][.rich-list][.navigation-sidebar][.data-table]
- * ├── row
+ * ├── row[.activatable]
  * │
- * ├── row
+ * ├── row[.activatable]
  * │
  * ┊
  * ╰── [rubberband]
  * ```
  *
- * `GtkListView` uses a single CSS node named listview. It may carry the
- * .separators style class, when `GtkListView`:show-separators property
- * is set. Each child widget uses a single CSS node named row. For
- * rubberband selection, a node with name rubberband is used.
+ * `GtkListView` uses a single CSS node named `listview`. It may carry the
+ * `.separators` style class, when [property@Gtk.ListView:show-separators]
+ * property is set. Each child widget uses a single CSS node named `row`.
+ * If the [property@Gtk.ListItem.activatable] property is set, the
+ * corresponding row will have the `.activatable` style class. For
+ * rubberband selection, a node with name `rubberband` is used.
  *
  * The main listview node may also carry style classes to select
  * the style of [list presentation](ListContainers.html#list-styles):